<?php
class MY_Controller extends CI_Controller{
	public function __construct(){
		parent::__construct();
        $this->load->helper('url');
        $this->load->library('session');
        $this->load->library('email');
        $this->load->helper('text');
        
        
        $this->load->model("banner_Model","bannerModel", true);
        $this->load->model("account_Model","accountModel", true);
        $this->load->model("language_Model","languageModel", true);
        $this->load->model("services_Model","servicesModel", true);
        $this->load->model("project_Model","projectModel", true);
        $this->load->model("faq_Model","faqModel", true);
        $this->load->model("information_Model","infoModel", true);
        $this->load->model("entry_Model","entryModel", true);
        $this->load->model("comment_Model","commentModel", true);
        $this->load->model("contact_Model","contactModel", true);
        $this->load->model("gallery_Model","galleryModel", true);
        $this->load->model("social_Model","socialModel", true);
        
        if(!$this->session->userdata('languageCode')) $this->session->set_userdata('languageCode', 'en');
        if(!$this->session->userdata('translations')) {
            $translations = include(APPPATH . 'core/language_'.$this->session->userdata('languageCode').'.php');
            $this->session->set_userdata('translations', $translations);
        }
        $this->_data['translations'] = $this->session->userdata('translations');
        $this->_data['languages'] = $this->getLanguages();
	}
    
	public function getLanguages() {
        $result = array();
        $language = $this->languageModel->get();
        foreach($language as $key => $value) {
            $result[$value['languageCode']] = $value;
        }
        return $result;
    }
    
    public function isPost(){
		return 'POST' == strtoupper($_SERVER['REQUEST_METHOD']);
	}
}
require_once 'baseController.php';
require_once 'adminController.php';